package com.lanou.myapp.news.recommendednews.contentrecommendednews;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.lanou.myapp.R;
import com.lanou.myapp.imageloader.GsonRequest;
import com.lanou.myapp.imageloader.VolleySingleton;

import java.util.logging.Handler;
import java.util.logging.LogRecord;

/**
 * Created by dllo on 16/1/20.
 */
public class ContentPictureNewsActivity extends AppCompatActivity{
    private ViewPager viewPager;
    private PictureViewPagerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_picture_commended_news_activity);
        viewPager = (ViewPager) findViewById(R.id.viewPager);

        int num = viewPager.getCurrentItem();
        Log.d("dsafddfsggg", num + "");

        adapter = new PictureViewPagerAdapter(this);
        Intent intent = getIntent();
        final String a = intent.getStringExtra("Key");
        String b = "http://interfacev5.vivame.cn/x1-interface-v5/json/gallery.json?platform=android&installversion=5.6.9.4&channelno=WDJTA2320480100&mid=5284047f4ffb4e04824a2fd1d1f0cd62&uid=3125&sid=ddeb07ea-e109-409d-80cf-8f9feee89196&type=3&id=";
        String url = b + a;
        Log.d("dfadasf", url);
        GsonRequest<PictureBeans> request = new GsonRequest<PictureBeans>(url, PictureBeans.class, new Response.Listener<PictureBeans>() {
            @Override
            public void onResponse(PictureBeans response) {
                adapter.addData(response.getData().getItems());
                Log.d("dfadsfds",response.getData().getItems().size() + "");
                viewPager.setAdapter(adapter);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        VolleySingleton.getInstance()._addRequest(request);
    }
}
